package com.lyt.springboot.util.algorithm;

import java.util.*;
import java.util.stream.Collectors;

public class S43 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        String[] s = input.split(" ");
        List<Integer> numbers = new ArrayList<>();
        for (int i = 0; i < s.length; i++) {
            numbers.add(Integer.valueOf(s[i]));
        }
        //从list取众数
        //用hashmap存
        int maxCount = 0;
        HashMap<Integer, Integer> hashMap = new HashMap<>();
        for (Integer num : numbers) {
            int count = hashMap.getOrDefault(num, 0) + 1;
            hashMap.put(num, count);
            maxCount = Math.max(maxCount, count);
        }
        final int finalMaxCount = maxCount;
        List<Integer> maxNums = hashMap.entrySet()
                .stream()
                .filter(entry -> entry.getValue() == finalMaxCount)
                .map(Map.Entry::getKey)
                .collect(Collectors.toList());
        System.out.println(maxNums);
        //取中位数
        Integer[] arr = new Integer[s.length];
        for (int i = 0; i < s.length; i++) {
            arr[i] = Integer.valueOf(s[i]);
        }
        Arrays.sort(arr);
        int midValue = 0;
        if(s.length%2 ==0 ) {
            int value = arr[arr.length/2 -1] +arr[arr.length/2 ];
            midValue = value/2;
        }else {
            midValue = arr[(arr.length+1)/2 -1];
        }
        System.out.println(midValue);

    }

}
